<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // 1. call apply
    // const person = {
    //   name: '刘德华',
    //   sing(str1, str2){
    //     console.log(this.name + '会唱' + str1 + str2)
    //   }
    // }

    // const obj = {
    //   name: '小偷'
    // }

    // person.sing('忘情水')
    // person.sing.call(obj, '忘情水', '冰雨')
    // person.sing.apply(obj, ['忘情水', '冰雨'])

    // 2. bind
    const person = {
      name: '刘德华',
      sing(str1, str2){
        console.log(this.name + '会唱' + str1 + str2)
      }
    }

    const obj = {
      name: '小偷'
    }
    const fn =  person.sing.bind(obj)
    fn('忘情水', '冰雨')
    fn('忘情水', '冰雨')
    fn('忘情水', '冰雨')
    fn('忘情水', '冰雨')
    fn('忘情水', '冰雨')
  </script>
</body>
</html>